#define cardIndex(modelName,url,map,aTh,aTd)
<div class="card-header">
    <h2 class="card-title text-info">#(modelName)</h2>
    <div class="progress">
        <div class="progress-bar bg-success" role="progressbar" style="width: 100%" aria-valuenow="100"
             aria-valuemin="0"
             aria-valuemax="100"></div>
    </div>
    <small class="card-subtitle">
        ###CRUDEWI:增加Create、读取Read、更新Update、删除Delete、导出export、擦wipe、导入import
        #if(map.C!=null&&map.C==1)
        #permission("/admin/"+url+"/addOrEdit")
        <a data-pjax href="/admin/#(url)/addOrEdit?p=#(page.pageNumber??1)&s=#(page.pageSize??10)"
           class="btn btn-sm btn-outline-primary waves-effect"><i
                class="zmdi zmdi-plus zmdi-hc-fw"></i>新增
        </a>
        #end
        #end
        #if(map.R!=null&&map.R==1)
        #permission("/admin/"+url)
        <button class="btn btn-sm btn-outline-success waves-effect" data-toggle="modal" data-target="#modal-large"><i
                class="zmdi zmdi-search zmdi-hc-fw"></i>查询
        </button>
        <a data-pjax href="/admin/#(url)" class="btn btn-sm btn-outline-success waves-effect"><i
                class="zmdi zmdi-close"></i>清空查询
        </a>
        #end
        #end
        #if(map.D!=null&&map.D==1)
        #permission("/admin/"+url+"/deletes")
        <button class="btn btn-sm btn-outline-danger waves-effect" id="delData"><i
                class="zmdi zmdi-local-drink zmdi-hc-fw"></i>删除
        </button>
        #end
        #end

        #if(map.I!=null&&map.I==1)
        #permission("/admin/"+url+"/importData")
        <a data-pjax href="javascript:void (0)" id="importInput" class="btn btn-sm btn-outline-info waves-effect"><i
                class="zmdi zmdi-upload zmdi-hc-fw"></i>导入数据</a>
        #end
        #end
        #if(map.E!=null&&map.E==1)
        #permission("/admin/"+url+"/exportData")
        <button class="btn btn-sm btn-outline-info waves-effect" onclick="xlsData()"><i
                class="zmdi zmdi-archive zmdi-hc-fw"></i>Excel导出
        </button>
        #end
        #end
        #@cardBtn?()
        <form data-pjax id="jmisForm" action="/admin/#(url)" method="get">
            <div class="modal fade" id="modal-large" tabindex="-1">
                <div class="modal-dialog modal-lg">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title pull-left"><i class="zmdi zmdi-search zmdi-hc-fw"></i>模糊查询条件
                            </h5>
                        </div>
                        <input type="hidden" name="p" id="p">
                        <input type="hidden" name="s" id="s" value="#(s)">
                        <div class="modal-body">
                            <div class="card-block">
                                <div class="row">
                                    #@cardQuery?()
                                </div>

                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="submit" class="btn btn-secondary btn--icon-text waves-effect"><i
                                    class="zmdi zmdi-search"></i> 查询
                            </button>
                            <button id="closeModal" type="button"
                                    class="btn btn-secondary btn--icon-text waves-effect"
                                    data-dismiss="modal"><i
                                    class="zmdi zmdi-close"></i> 关闭
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </small>
    <script>
        /*导出*/
        function xlsData() {
            var checkID = [];
            $("td:nth-child(1) :checked").each(function (i) {
                checkID[i] = $(this).val();
            });
            $.post("/admin/#(url)/exportData", {
                "fileName": '#(modelName)',
                "aThs": '#(aTh)',
                "aTds": '#(aTd)',
                "ids": checkID.toString()
            }, function (ret) {
                if (ret.state == "ok") {
                    showMsg(0, ret.msg);
                    window.location.href = "/admin/#(url)/download?fileName=" + ret.data.fileName;
                } else {
                    showMsg(3, ret.msg);
                }
            })
        }


        /*按钮点击事件*/
        $(".cardBtn").click(function (ret) {
            var postUrl = $(this).attr("data-url");
            $.post(postUrl, function (ret) {
                if (ret.state == "ok") {
                    showMsg(0, ret.msg);
                    $.pjax.reload('#pjax-container', {});
                } else {
                    showMsg(3, ret.msg);
                }
            })
        })

        $(document).ready(function () {
            $('.modal-backdrop').remove();
            $('body').css("overflow", "auto");
            /*全选*/
            $("#selectAll").click(function () {
                $("td:nth-child(1) :checkbox").not(":disabled").prop("checked", true);
            });
            /*全部选*/
            $("#unSelect").click(function () {
                $("td:nth-child(1) :checkbox,#all").not(":disabled").prop("checked", false);
            });
            /*反选*/
            $("#reverse").click(function () {
                $("td:nth-child(1) :checkbox").not(":disabled").each(function () {
                    $(this).prop("checked", !$(this).prop("checked"));
                });
            });

            //数据导入
            $('#importInput').click(function () {
                var slider = document.createElement("form");
                $(slider).attr("method", "post");
                $(slider).attr("id", "ajForm");
                $(slider).attr("enctype", "multipart/form-data");
                $(slider).attr("action", "/admin/#(url)/importData");
                $(slider).append("<input type='file' required name=\"excelFile\" class='swal-content__input form-control'/>")
                swal({
                    title: "仅支持excel文件导入！",
                    html: slider.outerHTML,
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                }).then(function () {
                    if ($('input[ name="excelFile"]').val() == "") {
                        showMsg(3, "请选择表格文件");
                        return;
                    }
                    var $this = $(this);
                    $("#ajForm").ajaxSubmit({
                        dataType: "json"
                        , beforeSubmit: function () {
                            $('.swal2-styled').click(function () {
                                $this.attr("disabled", "disabled").html("导入中...");
                            })
                        }
                        , success: function (ret) {
                            if (ret.state == "ok") {
                                showMsg(0, ret.msg);
                                //$.pjax.reload("#pjax-container", {});
                                var url = "/admin/#(url)";
                                if (ret.data) {
                                    url += "?ids=" + ret.data.serial;
                                }
                                $.pjax({url: url, container: "#pjax-container"});
                                $this.html("提交").removeAttr("disabled");
                            } else {
                                showMsg(2, ret.msg);
                            }
                        }
                    });
                    $(this).removeClass('swal-button--loading');
                }).catch(swal.noop);
            })




        });

        /*多条数据删除*/
        $("#delData").click(function () {
            var checkID = [];
            $("td:nth-child(1) :checked").each(function (i) {
                checkID[i] = $(this).val();
            });
            if (checkID.length == 0) {
                showMsg(2, "请先选择需要操作的数据行！")
                return;
            } else {
                $.post("/admin/#(url)/deletes?ids=" + checkID.toString(), function (ret) {
                    if (ret.state == "ok") {
                        showMsg(0, ret.msg);
                        $.pjax({url: '/admin/#(url)', container: '#pjax-container'});
                    } else {
                        showMsg(3, ret.msg);
                    }
                })
            }

        })

        /*数据删除*/
        function deleteData(id) {
            $.post("/admin/#(url)/deletes?ids=" + id + "&p=#(page.pageNumber??1)&s=#(page.pageSize??10)", function (ret) {
                if (ret.state == "ok") {
                    showMsg(0, ret.msg);
                    $.pjax({
                        url: '/admin/#(url)?p=#(page.pageNumber??1)&s=#(page.pageSize??10)',
                        container: '#pjax-container'
                    });
                } else {
                    showMsg(3, ret.msg);
                }
            })
        }

        $("#jmisTable tr").each(function () {
            $(this).children("td").each(function () {
                if (this.hasAttribute("data-column") && 'undefined' !== $(this).data("column")) {
                    if (!isEmpty($(this).children("a"))) {
                        var text = $(this).children("a").text().replace(/[\r\n\t\s]/g, "");//去掉回车换行空格和制表位
                        text = text.toString().length > 12 ? text.substring(0, 12) + "..." : text;
                        $(this).children("a").text(text);
                    } else {
                        var text = $(this).text().replace(/[\r\n\t\s]/g, "");//去掉回车换行空格和制表位
                        text = text.toString().length > 12 ? text.substring(0, 12) + "..." : text;
                        $(this).children("div").text(text);
                    }
                    var t = $(this).parent().children("td[data-name='" + $(this).data('column') + "']");
                    if (t.length > 0) {
                        t.replaceWith(this)
                    } else {
                        $(this).remove();
                    }
                }
            })
        })
    </script>
</div>
<div class="card-block" style="overflow: auto">
    #if(map.S!=null&&map.S==1)
    <div class="margin-top row">
        #@cardBlock()
    </div>
        #@adminPaginate(page, "/admin/"+url)
    #else
        #@cardIndexTable(url)
    #end
</div>
#end
#define cardIndexTable(url)
<table class="table table-hover table-sm mb-0">
    <thead>
    <tr class="text-info">
        #if(map.D!=null&&map.D==1)
        #permission("/admin/"+url+"/deletes")
        #@checkBoxBtn()
        #end
        #else if(map.B!=null&&map.B==1)
        #@checkBoxBtn()
        #end

        #for(y:aTh)
        #if(y!=null)
        <th>
            <div>#(y)</div>
        </th>
        #end
        #end
        #if(map.O!=null&&map.O==1)
        <th>
            <div>操作</div>
        </th>
        #end
    </tr>
    </thead>
    <tbody id="jmisTable">
    #for(x : page.getList()??)
    <tr>
        #if(map.D!=null&&map.D==1)
        #permission("/admin/"+url+"/deletes")
        #@checkBoxList()
        #end
        #else if(map.B!=null&&map.B==1)
        #@checkBoxList()
        #end
        #if(aTd.length>0 && aTd.get(0)!=0+'')
        #for(y:aTd)
        <td data-name="#(y)">
            <div title="#if(y=='createAc')#for(xx:accountList)#if(xx.id == x.get(y))#(xx.fullName) #end #end #else #(x.get(y)) #end">
                #if(y=='createAt')
                #date(x.get(y),"yyyy-MM-dd HH:mm")
                #else if(y=='createAc')
                #for(xx:accountList)
                #if(xx.id == x.get(y))
                #(xx.fullName)
                #end
                #end
                #else
                #(x.get(y)!=null && x.get(y).toString().length()>25 ? x.get(y).toString().substring(0,25)+"..." :
                x.get(y))
                #end
            </div>
        </td>
        #end
        #@cardIndexTbody?()
        #end
        #if(map.O!=null&&map.O==1)
        <td>
            <div style="width: 100%">
                #@tableBtn?(url)
                #@cardIndexBtn?()
            </div>
        </td>
        #end
    </tr>
    #end
    </tbody>
</table>
#@adminPaginate(page, "/admin/"+url)
#end
###复选框操作按钮
#define checkBoxBtn()
<th style="width: 2%">
    <div class="btn-group">
        <button type="button" class="btn btn-sm btn-secondary dropdown-toggle-split" data-toggle="dropdown">
            <span class="caret"></span>
        </button>
        <ul class="dropdown-menu">
            <li>
                <button class="dropdown-item" id="selectAll">全选</button>
            </li>
            <li>
                <button class="dropdown-item" id="unSelect">全不选</button>
            </li>
            <li>
                <button class="dropdown-item" id="reverse">反选</button>
            </li>
        </ul>
    </div>
</th>
#end

###复选框列表
#define checkBoxList()
<td>
    <label class="custom-control custom-checkbox">
        <input type="checkbox" value="#(x.id)" class="custom-control-input">
        <span class="custom-control-indicator"></span>
    </label>
</td>
#end

###禁用的复选框
#define checkBoxDisabled()
<td>
    <label class="custom-control custom-checkbox">
        <input type="checkbox" disabled value="#(x.id)" class="custom-control-input">
        <span class="custom-control-indicator"></span>
    </label>
</td>
#end

#define tableBtn(url)
#if(map.U!=null&&map.U==1)
#permission("/admin/"+url+"/addOrEdit")
<a data-pjax class="btn btn-sm btn-outline-info waves-effect"
   href="/admin/#(url)/addOrEdit?id=#(x.id)&p=#(page.pageNumber??1)&s=#(page.pageSize??10)" title="修改">
    <i class="zmdi zmdi-edit"></i>修改
</a>
#end
#end

#if(map.D!=null&&map.D==1)
#permission("/admin/"+url+"/deletes")
<button class="btn btn-sm btn-outline-danger waves-effect" onclick="deleteData('#(x.id)')" title="删除">
    <i class="zmdi zmdi-local-drink zmdi-hc-fw" ></i>删除
</button>
#end
#end
#end
<script src="/assets/app/table.js?v=#(resource_version)"></script>